﻿<UserControl x:Class="FileExplorer.WPF.Views.ProgressDialogView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:bc="http://www.quickzip.org/BaseControls"
             xmlns:def="clr-namespace:FileExplorer.WPF.Defines"
             xmlns:conv="clr-namespace:QuickZip.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="500">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Common/ProgressBar.xaml" />
                <ResourceDictionary Source="pack://application:,,,/FileExplorer3.WPF;component/Themes/Common/Converters.xaml" />
            </ResourceDictionary.MergedDictionaries>
            
            <conv:StripPathConverter x:Key="spc" />
            <conv:AddBracketConverter x:Key="abc" />
            <conv:TimeSpanToStrConverter x:Key="tstsc" />
            <conv:TagToBoldConverter x:Key="ttb" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Border BorderBrush="#606B75"  BorderThickness="0.5" Height="160" Width="400" x:Name="rootBorder" >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
                <RowDefinition Height="*" />
                <RowDefinition Height="40" />
            </Grid.RowDefinitions>

            <Rectangle Grid.Row="0" Fill="{StaticResource progressTitleBrush}" />
            <Rectangle Grid.Row="1" Fill="#FFFFFF" />
            <Rectangle Grid.Row="2" Fill="#F0F0F0" />

            <bc:HtmlTextBlock Foreground="White" Html="{Binding Header}" Margin="20,0,0,0" 
                          FontSize="18" VerticalAlignment="Center"  />


            <StackPanel Grid.Row="1" Margin="25,10" Orientation="Vertical">
                <Grid>
                    <StackPanel x:Name="layoutBrief"  Orientation="Vertical"  MinHeight="35" Visibility="{Binding IsExpanded, ElementName=expInfo, Converter={StaticResource fbtv}}" >
                        <bc:HtmlTextBlock Html="{Binding Message, Converter={StaticResource ttb}}"  />
                        <WrapPanel>
                            <TextBlock Text="{Binding SubMessage}" />
                            <!--<TextBlock Text="about " />
                            <TextBlock Text="{Binding TimeRemain, Converter={x:Static c:TimeSpanToStrConverter.Instance}}"/>
                            <TextBlock Text="remaining " />-->
                        </WrapPanel>

                        <!--<TextBlock Text="{Binding Message}" Visibility="{Binding IsFailed, Converter={x:Static c:vc_BoolToVisiblity.Instance}}"/>-->
                    </StackPanel>
                    <StackPanel x:Name="layoutDetail" Orientation="Vertical" Visibility="{Binding IsExpanded, ElementName=expInfo, Converter={StaticResource btv}}" >
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition Height="30" />
                            </Grid.RowDefinitions>

                            <!--From Row-->
                            <DockPanel  Grid.Row="0" Grid.Column="0" >
                                <TextBlock DockPanel.Dock="Left" Text="{x:Static def:Strings.strFrom}" />
                                <TextBlock Text=":" />
                            </DockPanel>
                            <DockPanel Grid.Row="0" Grid.Column="1">
                                <TextBlock Text="{Binding Source, Converter={StaticResource spc} }" FontWeight="UltraBold" />
                                <TextBlock Text="{Binding Source, Converter={StaticResource abc} }" />
                            </DockPanel>
                            <!--To Row-->
                            <DockPanel  Grid.Row="1" Grid.Column="0" >
                                <TextBlock DockPanel.Dock="Left" Text="{x:Static def:Strings.strTo}" />
                                <TextBlock Text=":" />
                            </DockPanel>
                            <DockPanel Grid.Row="1" Grid.Column="1">
                                <TextBlock Text="{Binding Destination, Converter={StaticResource spc} }" FontWeight="UltraBold" />
                                <TextBlock Text="{Binding Destination, Converter={StaticResource abc} }" />
                            </DockPanel>

                            <!--Remain Time Row-->
                            <DockPanel  Grid.Row="2" Grid.Column="0" >
                                <TextBlock DockPanel.Dock="Left" Text="{x:Static def:Strings.strRemainTime}" />
                                <TextBlock Text=":" />
                            </DockPanel>
                            <DockPanel Grid.Row="2" Grid.Column="1">
                                <TextBlock Text="{Binding TimeRemain.RequiredTime, Converter={StaticResource tstsc}}"/>
                            </DockPanel>

                            <!--Remain Item Row-->
                            <DockPanel  Grid.Row="3" Grid.Column="0" >
                                <TextBlock DockPanel.Dock="Left" Text="{x:Static def:Strings.strRemainItem}" />
                                <TextBlock Text=":" />
                            </DockPanel>
                            <DockPanel Grid.Row="3" Grid.Column="1">
                                <TextBlock Text="{Binding UnprocessedEntries}" />
                            </DockPanel>

                            <!--Message Row-->
                            <DockPanel  Grid.Row="4" Grid.Column="0" >
                                <TextBlock DockPanel.Dock="Left" Text="{x:Static def:Strings.strMessage}" />
                                <TextBlock Text=":" />
                            </DockPanel>
                            <DockPanel Grid.Row="4" Grid.Column="1">
                                <TextBlock Text="{Binding SubMessage}" TextWrapping="WrapWithOverflow" />
                            </DockPanel>


                        </Grid>

                    </StackPanel>
                </Grid>
                <Grid>
                    <ProgressBar x:Name="pBar" Margin="0,10" Height="15" Value="{Binding TimeRemain.Progress, Mode=OneWay}"  
                                 IsIndeterminate="{Binding TimeRemain.IsIndeterminate, Mode=OneWay}" />
                    <!--<ProgressBar x:Name="pBar2" Margin="0,10" Height="15" Value="{Binding TimeRemain.Progress, Mode=OneWay}"  
                             Style="{DynamicResource staticProgressBarStyle}" Visibility="Hidden"                             
                             IsIndeterminate="False" />-->
                </Grid>
            </StackPanel>


            <!-- Bottom -->
            <DockPanel Grid.Row="2" Margin="25,8" LastChildFill="False">
                <Button DockPanel.Dock="Right" Margin="5,0"  Width="80" x:Name="btnClose"  
                        Content="{x:Static def:Strings.strClose}" Command="{Binding CloseCommand}"
                            Visibility="{Binding IsCompleted, Converter={StaticResource btv}}"                             
                             />
                <Button DockPanel.Dock="Right" Margin="5,0"  Width="80" x:Name="btnCancel" 
                            Command="{Binding CancelCommand}"
                            Content="{x:Static def:Strings.strCancel}"
                            Visibility="{Binding IsCancelEnabled, Converter={StaticResource btv}}"                             
                             />
                <!--<Button DockPanel.Dock="Right" Margin="5,0"  Width="80" x:Name="btnRestart" 
                            Content="{x:Static def:Strings.strRestart}"
                            Visibility="{Binding IsRestartEnabled, Converter={StaticResource btv}}" 
                             />
            <Button DockPanel.Dock="Right" Margin="5,0"  Width="80" x:Name="btnPause" 
                            Content="{x:Static def:Strings.strPause}"
                            Visibility="{Binding IsPauseEnabled, Converter={StaticResource btv}}" 
                             />
            <Button DockPanel.Dock="Right" Margin="5,0"  Width="80" x:Name="btnResunme" 
                            Content="{x:Static def:Strings.strResume}"
                            Visibility="{Binding IsResumeEnabled, Converter={StaticResource btv}}" 
                             />-->
                <Expander x:Name="expInfo" DockPanel.Dock="Left" Header="{x:Static def:Strings.strMoreInformation}" IsExpanded="False" />
            </DockPanel>
        </Grid>
    </Border>
    <UserControl.Triggers>
        <EventTrigger SourceName="expInfo" RoutedEvent="Expander.Expanded">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard  TargetName="expInfo"  TargetProperty="Header">
                        <StringAnimationUsingKeyFrames Duration="0:0:0.0">
                            <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="{x:Static def:Strings.strLessInformation}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
                <BeginStoryboard>
                    <Storyboard  TargetName="rootBorder"  TargetProperty="Height">
                        <DoubleAnimation From="160" To="220" Duration="0:0:0.1" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
        <EventTrigger SourceName="expInfo" RoutedEvent="Expander.Collapsed" >
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard  TargetName="expInfo"  TargetProperty="Header">
                        <StringAnimationUsingKeyFrames Duration="0:0:0.0">
                            <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="{x:Static def:Strings.strMoreInformation}" />
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
                <BeginStoryboard>
                    <Storyboard  TargetName="rootBorder"  TargetProperty="Height">
                        <DoubleAnimation From="220" To="160" Duration="0:0:0.1" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
    </UserControl.Triggers>
</UserControl>
